var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [{
			colkey : "dname",
			name : "部门",

		},{
			colkey : "name",
			name : "姓名",
			
		},{
			colkey : "countMoney",
			name : "扣罚金额",
			
		},{
			colkey : "countNumber",
			name : "扣罚次数",
			
		}],
		jsonUrl : rootPath + '/hrattendance/attendance_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#addOrder").click("click", function() {
		addAccount();
	});
	$("#editOrder").click("click", function() {
		editAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
			
		});
	});
	
});





function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "编辑员工信息 ",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/hrstaff/staff_edit.shtml?id=' + cbox
	});
}
function addAccount() {
	var cbox = grid.getSelectedCheckbox();
	pageii = layer.open({
		title : "新增员工信息",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/hrstaff/staff_add.shtml?id=' + cbox
	});
}
function addAccounts() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "新增档案信息",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/hrstaff/record_add.shtml?id=' + cbox
	});
}

function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/hrstaff/staff_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
	
}
/*删除档案*/
function delAccounts() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/hrstaff/record_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
	
}
